package com.kma.summer2012.client.services.request;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.kma.summer2012.client.ExceptionHandling.CrumbsRPCServiceException;
import com.kma.summer2012.shared.model.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RemoteServiceRelativePath("CrumbsRequestService")
public interface CrumbsRequestService extends RemoteService {

    Boolean sendchangeState(int id, String comment, int senderId) throws CrumbsRPCServiceException;

    UICrumbsRequest getById(int id);

    public UICrumbsClient addNewClient(UICrumbsClient newClient) throws CrumbsRPCServiceException;

    public UICrumbsRequest addNewRequest(UICrumbsRequest newRequest) throws CrumbsRPCServiceException;

    public List<UICrumbsRequest> getAllRequests() throws CrumbsRPCServiceException;

    public UICrumbsRequest editOperatorRequest(UICrumbsRequest request) throws CrumbsRPCServiceException;

    public UICrumbsRequest initialize(UICrumbsRequest request) throws CrumbsRPCServiceException;

    public UICrumbsRequest getLastCommentFromManger(UICrumbsRequest request) throws CrumbsRPCServiceException;

    public Boolean editManagerRequest(int request_id) throws CrumbsRPCServiceException;

    public UICrumbsClient updateClient(UICrumbsClient client) throws CrumbsRPCServiceException;

    public Boolean saveComments(UIComment comment) throws CrumbsRPCServiceException;

    public Boolean assignRequest(int user_id, int request_id, Date assignDateBegin, Date assignDateEnd) throws CrumbsRPCServiceException;

    public Boolean closeRequest(Map<UICrumbsToolItem, Integer> actualToolsAndAmount, UICrumbsRequest request, String comment, int userId, String date) throws CrumbsRPCServiceException;

    public Boolean sendForProcessing(int idSender, int idRequest) throws CrumbsRPCServiceException;

    public Boolean sendAllForProcessing(int idSender, List<UICrumbsRequest> requests) throws CrumbsRPCServiceException;

    public Integer saveDate(int requestID, Date start, Date end) throws CrumbsRPCServiceException;

    public Integer updateDate(int requestID, Date start, Date end) throws CrumbsRPCServiceException;

    List<UICrumbsRequest> getAllForUser(UICrumbsUser user) throws CrumbsRPCServiceException;

    List<UICrumbsRequest> getAllClosed() throws CrumbsRPCServiceException;

    public Boolean getHistoryForRequest(int requestID, int commenterID) throws CrumbsRPCServiceException;

    public Boolean deleteRequests(List<Integer> requests) throws CrumbsRPCServiceException;

    public static class App {
        private static final CrumbsRequestServiceAsync ourInstance = (CrumbsRequestServiceAsync) GWT.create(CrumbsRequestService.class);

        public static CrumbsRequestServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
